﻿using System.Windows.Markup;

namespace PMIS.Common.EnumHelper
{
    public enum Gender
    {
        女 = 0,
        男 = 1,
    };

    public class EnumSource : MarkupExtension
    {
        private readonly Type _type;

        public EnumSource(Type type)
        {
            _type = type;
        }

        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            return Enum.GetValues(_type)
                .Cast<object>()
                .Select(e => new { Value = (int)e, Name = e.ToString() });
        }
    }
}
